
function Base.LoadCurLevel()
	
	LoadMap( "maps/testmap2.map" );
	
	
	
end

function Base.Think()
	
	timer.Think();
	
	MapEventThink();
	
	Entity.Think();
	
end

function Base.BattleSystemThink()
	
	
	timer.Think();
	
	Entity.Think();
	
	for k, v in pairs( BattleEnts ) do
	
		if( not v:IsValid() ) then
			
			table.remove( BattleEnts, k );
			
		else
			--[[
		
		if( v.isEnemy and v.Data.IdleMsgs and #v.Data.IdleMsgs > 0 ) then
		
			if( not v:GetTable().NextIdleMsg or v:GetTable().NextIdleMsg < 0 ) then
				v:GetTable().NextIdleMsg = math.random( v.Data.MinIdleMsgPause, v.Data.MaxIdleMsgPause ) + GetTicks();
			end
			
			if( GetTicks() > v:GetTable().NextIdleMsg ) then
			
				v:GetTable().NextIdleMsg = math.random( v.Data.MinIdleMsgPause, v.Data.MaxIdleMsgPause ) + GetTicks();
				
				local msgid = math.random( 1, #v.Data.IdleMsgs );
				local msg = v.Data.IdleMsgs[msgid];
				local width = GetStringWidth( "Uni14", msg );
				
				LuaC.TimedUIMessage( msg, v:GetCenter().x - width * .5, v:GetPos().y, width, 1500, math.random( 100, 1000 ) );
				
			end
				
		end
			
			]]--
		
		end
		
	end
	
end

DrawMousePos = true;

function DrawDebugMouse()
	
	if( DrawMousePos ) then
		
		local mpos = GetMousePos();
		local cpos = GetCameraPos();
		
		if( G.RPGBattle ) then
			
			cpos = { x = 0, y = 0 };
			
		end
		
		local pos = { x = 0, y = 0 };
		
		pos.x = mpos.x + cpos.x;
		pos.y = mpos.y + cpos.y;
		
		local w = GetStringWidth( "Uni14", pos.x .. ", " .. pos.y );
		
		Draw.SetColor( 0, 0, 0, 1 );
		Draw.Rect( mpos.x - 5, mpos.y + 20, w + 10, 30 );
		Draw.SetColor( 1, 1, 1, 1 );
		Draw.Text( "Uni14", pos.x .. ", " .. pos.y, mpos.x, mpos.y + 25 );
		
	end
	
end

function Base.PostDraw() 
	
	DrawMsgBoxes();
	
	DrawUIMessages();
	
	DrawDebugMouse();
	
	DrawFreeText();
	
end

function Base.PreBlackBarRPGBattleDraw()
	
	Weather.DoSnow();
	
end

function Base.PostRPGBattleDraw()

	for k, v in pairs( PopupText ) do
		
		Draw.SetColor255( 255, 255, 255, v.Alpha );
		Draw.Text( v.Font, v.Text, v.x, v.y );

		v.y = v.y - v.Speed * GetDPS();

		v.Speed = v.Speed - math.abs( v.OrigSpeed * 3 ) * GetDPS();
		
		if( v.y > v.startY ) then
			
			v.Alpha = v.Alpha - v.Fadeout * GetDPS();
			v.y = v.startY;
			
		end
		
		if( v.Alpha <= 0 ) then

			PopupText[k] = nil;

		end

	end
	
	DrawUIMessages();
	
	DrawMsgBoxes();

	DrawDebugMouse();
	
	if( BattleDrawFunc ) then
		
		BattleDrawFunc();
		
	end
	
	DrawBattleText();
	
	DrawFreeText();
	
end
